package com.doushu.dispatch.mapper;

import com.doushu.dispatch.entity.ItemFrom;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ItemFromMapper {

//    @Select({
//            "<script>"
//                    + "INSERT INTO ds_itemfromlist(sourceName,payBuyerCnt,payRate,favBuyerCnt,sourceId,addCartBuyerCnt,uv,pv,iid,datatime,terminal,sid) VALUES"
//                    + "<foreach collection='list' item='item' separator=','>"
//                    + "(#{item.sourceName},#{item.payBuyerCnt},#{item.payRate},#{item.favBuyerCnt},#{item.sourceId},#{item.addCartBuyerCnt},#{item.uv},#{item.pv},#{item.iid},#{item.datatime},#{item.terminal},#{item.sid})"
//                    + "</foreach>"
//                    + "</script>"
//    })
//    Integer insertItemFroms(List<ItemFrom> items);

    @Insert("INSERT INTO ds_itemfromlist(sourceName,payBuyerCnt,payRate,favBuyerCnt,sourceId,addCartBuyerCnt,uv,pv,iid,datatime,terminal,sid) VALUES (#{sourceName},#{payBuyerCnt},#{payRate},#{favBuyerCnt},#{sourceId},#{addCartBuyerCnt},#{uv},#{pv},#{iid},#{datatime},#{terminal},#{sid})")
    Integer insertItemFrom(ItemFrom item);

    @Select({"SELECT 1 FROM ds_itemfromlist WHERE sid=#{sid} AND datatime=#{datatime} AND iid=#{iid} LIMIT 1"})
    Boolean existsBySidAndDatatimeAndIid(@Param("sid")Long sid, @Param("datatime")String datatime, @Param("iid")Long iid);
}
